package com.example.classassistant;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

public class RandomRollCall {
    private Class classroom;
    private Random random = new Random();

    public RandomRollCall(Class classroom) {
        this.classroom = classroom;
    }

    // 随机抽取小组
    public int pickRandomGroup() {
        List<Group> groups = classroom.getGroups();
        if (groups.isEmpty()) return -1;
        int index = random.nextInt(groups.size());
        return index;
    }

    // 从选定的小组中随机抽取学生
    public int pickRandomStudentFromGroup(Group group) {
        List<Student> students = group.getStudents();
        if (students.isEmpty()) return -1;
        int index = random.nextInt(students.size());
        return index;
    }


}